Skip to content

fix(browser): surface sidecar failures and keep builds alive past request timeouts - #1173

Open
linus-liu-web wants to merge 1 commit into
Tencent:mainfrom
linus-liu-web:fix/agent-browser-sidecar-failures
Open

linus-liu-web wants to merge 1 commit into
Tencent:mainfrom
linus-liu-web:fix/agent-browser-sidecar-failures

Conversation

@linus-liu-web

@linus-liu-web linus-liu-web commented Nov 21, 2026 •

Copy link
Copy Markdown

Companion: #1172 documents the Agent browser sidecar and its prebuild path; this PR fixes the underlying failure reporting and build cancellation.

What changed

On a Compose install, opening the Agent browser panel while the first sidecar image build outlives the request ends with the misleading message Agent 浏览器启动失败:当前运行环境不支持,或 Chromium 不可用, and the build is cancelled with the request.

  • internal/httpapi/browser.go caps an ensure request at 4 minutes.
  • internal/runtime/browser.go derived the 15-minute sidecar build context from that request context, so when the request expired docker build was killed and left [docker-buildx] <defunct>; the next attempt rebuilt from scratch.
  • runtime.EnsureSandboxBrowser turns every error into a warning event and returns nil, and engine.ensureRunBrowser turned nil into the generic unsupported-environment message, so neither the panel nor the logs showed the build failure.

Changes:

  1. Add runtime.EnsureSandboxBrowserWithError, which returns the browser plus the real reason it is unavailable. EnsureSandboxBrowser keeps the failure-tolerant node behavior (nil result and the existing browser.unavailable warning event), so optional in-node browser tooling is unchanged.
  2. engine.ensureRunBrowser now returns Agent 浏览器启动失败:<real cause>, so the panel shows the build error (the image build error already carries the tail of the Docker output) instead of a fixed message. runtime.ErrBrowserDisabled replaces the duplicated disabled string.
  3. Build the sidecar image on context.WithTimeout(context.WithoutCancel(ctx), 15*time.Minute), so an interactive timeout only stops waiting: the image build completes and the next request starts the browser immediately. If the caller expired while the image was built, the returned error says the image is ready and asks to reopen the browser.

Refs #1160.

Scope

  • Platform core / API / runner
  • Public adapter / deployment
  • Classic
  • Portable
  • Shared behavior contract
  • Installer / CLI
  • Documentation only

Compatibility

No API, schema or runner-protocol change. Interactive browser failures now report the underlying cause instead of a fixed message; EnsureSandboxBrowser keeps its existing signature and behavior for node execution. The detached build can outlive a cancelled request for up to 15 minutes, bounded by the existing image-build timeout.

Validation

  • go vet ./internal/runtime ./internal/engine passes; gofmt clean.
  • New regression tests pass: go test ./internal/runtime -run 'TestAgentBrowserBuildOutlivesRequestTimeout|TestEnsureSandboxBrowserWithError' -count=1
    • a build started with a 100 ms request context finishes and writes the image marker instead of being cancelled, the caller receives the retry hint, and the next call returns the MCP server;
    • a failing build surfaces docker build browser image ... connection timed out through the error-returning helper, while EnsureSandboxBrowser still returns nil;
    • the disabled browser and missing workspace cases are explicit errors for interactive callers.
  • go test ./internal/engine -run 'Browser|Conversation' -count=1 passes.
  • go test ./internal/runtime -count=1: one failure, TestLocalWorkspaceGitDiscoveryCannotReachParent, reproduced identically on the unmodified base commit (d58a85a); it is pre-existing and unrelated to this change.
  • python3 scripts/check-public.py passes.
  • Manual reproduction on a Compose install (what these tests pin): the first ensure blocked for ~240 s and returned the generic Chromium message with no image and a defunct builder; after a manual long build, the same ensure returned available: true in ~2 s.
  • Not run: full go test -p=2 ./... (the repository requires building the embedded chatbot frontend first).

Safety

  • I did not include credentials, internal endpoints, production data, or organization-specific infrastructure.
  • I preserved user files and unrelated changes.
  • I updated generated Classic host bundles when applicable. (n/a — no Classic change)
  • I documented third-party content and licensing changes when applicable. (n/a)

…uest timeouts

Opening the Agent browser panel on a Compose install whose first sidecar image
build outlives the request reports "当前运行环境不支持,或 Chromium 不可用",
and the build itself is cancelled with the request: the ensure request caps at
4 minutes, the 15-minute image build context was derived from it, so docker
build is killed and leaves a defunct builder, then the next attempt rebuilds
from scratch. The runtime helper drops every error to a warning, so neither the
panel nor the logs show the build failure.

Return the real reason to interactive callers and keep the build running:

- add runtime.EnsureSandboxBrowserWithError; EnsureSandboxBrowser keeps the
  failure-tolerant node behavior and the existing warning event;
- report the underlying error from engine.ensureRunBrowser, and reuse
  runtime.ErrBrowserDisabled for the disabled deployment;
- build the sidecar image on a context detached from the caller cancellation,
  and say the image is ready when the caller expired first.

Refs Tencent#1160
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant